/*
 *  Class Token
 *  
 *  Each token is represented by its type and value. 
 */

public class Token {
	
	// list of tokens
	static final int EOF = 0;
	static final int SM = 1;
	static final int FA = 2;
	static final int LP = 3;
	static final int RP = 4;
	static final int LB = 5;
	static final int RB = 6;
	static final int EQ = 7;
	static final int AO = 8;
	static final int PO = 9;
	static final int MO = 10;
	static final int TO = 11;
	static final int DO = 12;
	static final int MD = 13;
	static final int NE = 14;
	static final int LO = 15;
	static final int LA = 16;
	static final int NM = 17;
	static final int ST = 18;
	static final int KW = 19;
	static final int CLASS = 20;
	static final int ELSE = 21;
	static final int IF = 22;
	static final int INT = 23;
	static final int FLOAT = 24;
	static final int BOOLEAN = 25;
	static final int STRING = 26;
	static final int RETURN = 27;
	static final int STATIC = 28;
	static final int WHILE = 29;
	static final int BL = 30;
	static final int ID = 31;
	
	private int token; // Type of of token
	private String lexeme; // The lexeme

	public Token(int token, String lexeme) {
		this.token = token;
		this.lexeme = lexeme;
	}

	// Constructor that takes only the int of the token and sets the lexeme accordignly
	public Token(int token) {
		switch(token) {
			case 0:
				this.token = token;
				this.lexeme = "EOF";
				break;
			case 1:
				this.token = token;
				this.lexeme = ";";
				break;
			case 2:
				this.token = token;
				this.lexeme = ",";
				break;
			case 3:
				this.token = token;
				this.lexeme = "(";
				break;
			case 4:
				this.token = token;
				this.lexeme = ")";
				break;
			case 5:
				this.token = token;
				this.lexeme = "{";
				break;
			case 6:
				this.token = token;
				this.lexeme = "}";
				break;
			case 7:
				this.token = token;
				this.lexeme = "==";
				break;
			case 8:
				this.token = token;
				this.lexeme = "=";
				break;
			case 9:
				this.token = token;
				this.lexeme = "+";
				break;
			case 10:
				this.token = token;
				this.lexeme = "-";
				break;
			case 11:
				this.token = token;
				this.lexeme = "*";
				break;
			case 12:
				this.token = token;
				this.lexeme = "/";
				break;
			case 13:
				this.token = token;
				this.lexeme = "%";
				break;
			case 14:
				this.token = token;
				this.lexeme = "!=";
				break;
			case 15:
				this.token = token;
				this.lexeme = "||";
				break;
			case 16:
				this.token = token;
				this.lexeme = "&&";
				break;
			case 17:
				this.token = token;
				this.lexeme = "A NUMBER";
				break;
			case 18:
				this.token = token;
				this.lexeme = "A STRING";
				break;
			case 19:
				this.token = token;
				this.lexeme = "A KEYWORD";
				break;
			case 20:
				this.token = token;
				this.lexeme = "class";
				break;
			case 21:
				this.token = token;
				this.lexeme = "else";
				break;
			case 22:
				this.token = token;
				this.lexeme = "if";
				break;
			case 23:
				this.token = token;
				this.lexeme = "int";
				break;
			case 24:
				this.token = token;
				this.lexeme = "float";
				break;
			case 25:
				this.token = token;
				this.lexeme = "boolean";
				break;
			case 26:
				this.token = token;
				this.lexeme = "String";
				break;
			case 27:
				this.token = token;
				this.lexeme = "return";
				break;
			case 28:
				this.token = token;
				this.lexeme = "static";
				break;
			case 29:
				this.token = token;
				this.lexeme = "while";
				break;
			case 30:
				this.token = token;
				this.lexeme = "A BOOLEAN";
				break;
			case 31:
				this.token = token;
				this.lexeme = "AN ID";
				break;
			default:
				break;
		}
	}

	// Returns the type of the token
	public int getTokenType() {
		return token;
	}

	// Returns the lexeme of the token
	public String getLexeme() {
		return lexeme;
	}

	// Returns a string representation of the token
	public String toString() {
		return token + "\t" + lexeme;
	}
}